﻿
AntiCheat_fnc_globalChat = 
{
	private ["_name","_talk"];
	_name = _this select 0;
	_talk = _this select 1;
	hint (_name + "使用了作弊插件: " + _talk);
};

AntiCheat_fnc_modsCheck =
{
	private ["_newGroup"];
	if (isServer) exitWith {};
	if (!(isNil "AntiCheat_Checked")) exitWith{}; // One Existence Only
	AntiCheat_Checked = true;
	AntiCheat_mods = ["TVS","RTX","RTX_FZ","MGI_TG_V2","ccccc","balca_debug_tool","vaa_arsenal","KRON_SupportCall","yq_mod_SuperSoldier","dsl_gear_selection","loki_lk","elite_sway","SOLDIER","elite","remove_fatigue_group","DRI_nofatigue","fhq_debug","NSS_Admin_Console","VDEBUG","NW_RTSE","panda_data","GIG_Scud","Extended_Init_EventHandlers","Extended_Fired_EventHandlers","SSPCM","KA_VAA","HJ_ConfigExplorer","KA_Suitcase_Nuke"];
	AntiCheat_mods_name = ["TVS","U键军火库2","U键军火库3","MGI_TG_V2","M键菜单","试验场","U键军火库","呼叫支援","超级士兵","随心换装","超级A3","终极士兵-稳定瞄准","终极士兵-无晃动","终极士兵-无限体力","终极士兵-群体无限体力","DRI 无限体力","FHQ 控制台","NSS 控制台","VDEBUG 控制台","NW 脚本运行器","超级氢弹","3代洲际战略弹道核导弹","原子弹2","原子弹3","简单作弊","U 键军火库","超级试验场","洲际战略弹道核导弹"];
	AntiCheat_mods_name_eng = ["TVS","RTX","RTX_FZ","MGI_TG_V2","ccccc","proving ground","virtual arsenal anywhere","KRON Support Call","Super Soldier mode","dsl gear selection","super A3","half sway or remove sway","ultimate soldier","remove fatigue","remove fatigue group","DRI no fatigue","FHQ debug console","NSS admin console","VDEBUG console","NW realtime script engine","panda data","zhanlve daodan","nuclear 1","nuclear 2","nuclear 3","sspcm","KA_VAA","HJ_ConfigExplorer","ab_switch","KA_Suitcase_Nuke"];
	AntiCheat_mods_found = [];
	AntiCheat_effect_noAimSway = false;
	AntiCheat_effect_noRecoil = false;
	waitUntil {!(isNull player)}; // In case of JIP
	sleep 1;
	{
		if (isClass (configFile  >> "CfgPatches" >> _x) ) then
		{
			AntiCheat_mods_found set [count AntiCheat_mods_found,_forEachIndex];
		}
	} forEach AntiCheat_mods;
	if(getNumber(configFile>>"CfgMovesMaleSdr">>"States">>"AmovPknlMstpSrasWrflDnon_turnR">>"aimPrecision")==0) then
	{
		AntiCheat_effect_noAimSway = true;
	};
	if(unitRecoilCoefficient player==0) then
	{
		AntiCheat_effect_noRecoil = true;
	};
	if (count AntiCheat_mods_found == 0 && {not AntiCheat_effect_noAimSway} && {not AntiCheat_effect_noRecoil}) exitWith{};
	AntiCheat_string_first = true;
	if (count AntiCheat_mods_found > 0) then
	{
		{
			if (AntiCheat_string_first) then 
			{
				AntiCheat_string = (AntiCheat_mods_name select _x);
				AntiCheat_string_eng = (AntiCheat_mods_name_eng select _x);
				AntiCheat_string_first = false;
			}
			else
			{
				AntiCheat_string = AntiCheat_string + ", " + (AntiCheat_mods_name select _x);
				AntiCheat_string_eng = AntiCheat_string_eng + ", " + (AntiCheat_mods_name_eng select _x);
			};
		} forEach AntiCheat_mods_found;
	};
	if (AntiCheat_effect_noAimSway) then
	{
		if (AntiCheat_string_first) then 
		{
			AntiCheat_string = "无晃动插件";
			AntiCheat_string_eng = "unknown no sway";
			AntiCheat_string_first = false;
		};
		AntiCheat_string = AntiCheat_string + ", 无晃动插件";
		AntiCheat_string_eng = AntiCheat_string_eng + ", unknown no sway";
	};
	if (AntiCheat_effect_noRecoil) then
	{
		if (AntiCheat_string_first) then 
		{
			AntiCheat_string = "无后坐力插件";
			AntiCheat_string_eng = "unknown no recoil";
			AntiCheat_string_first = false;
		};
		AntiCheat_string = AntiCheat_string + ", 无后坐力插件";
		AntiCheat_string_eng = AntiCheat_string_eng + ", unknown no recoil";
	};
	[[name player,AntiCheat_string], "AntiCheat_fnc_globalChat", nil, false] spawn BIS_fnc_MP;
	_newGroup = createGroup side player;
	[player] joinSilent _newGroup;
	player addRating -1000000;
	player setPos [0,0,0];
	while{true} do
	{
		player globalChat "你已经被监测到挂载了作弊插件!";
		player globalChat "违禁插件：" + AntiCheat_string + "。请退出游戏，取消挂载。";
		player globalChat "Please unload " + AntiCheat_string_eng + " mod!!!";
		if(player getVariable ["INS_REV_PVAR_is_unconscious",false]) then {}
		else {player setDamage 1;player setPos [0,0,0];};
		sleep 1.5;
	};
};

publicVariable "AntiCheat_fnc_globalChat";
publicVariable "AntiCheat_fnc_modsCheck";


// Call everywhere
sleep 0.3;
[[], "AntiCheat_fnc_modsCheck", nil, true] spawn BIS_fnc_MP;
systemChat "反作弊已启动，不开挂还是战友";